package graph;

public class GrundyTag {
	public int minGrundy(int[] nextGrundy) {
		int n = nextGrundy.length;
		int[] tag = new int[n];
		for (int i = 0; i < n; ++i) {
			if (nextGrundy[i] < n) {
				tag[nextGrundy[i]] = 1;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (tag[i] == 0)
				return i;
		}
		return n;
	}

	public int xorGrundy(int[] grundy) {
		int n = grundy.length;
		int g = 0;
		for (int i = 0; i < n; ++i) {
			g ^= grundy[i];
		}
		return g;
	}
}
